package com.idheima.Set.TreeSet;



import java.util.Comparator;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
        TreeSet<Student> students = new TreeSet<>( (o1, o2)->{
            if (o1.getAge() == o2.getAge()) {
                return o1.getScore() - o2.getScore();
            }
            return o2.getAge() - o1.getAge();
    });



        //2.添加学生信息`
        students.add(new Student("狗哥", 18, 100));
        students.add(new Student("厂长", 19, 90));
        students.add(new Student("水子哥", 17, 80));
        students.add(new Student("圣枪哥", 18, 99));

        //3.打印结果
        students.forEach(System.out::println);
    }
}
